main_est_table <- function(){
  
  rownames <- c("\\quad Low HH health severity score {[}0/1{]} ",
                "",
                "\\quad HH health severity score",
                "",
                "\\quad Dependents {[}0/1{]}",
                "",
                "\\quad Over-50 {[}0/1{]}",
                "",
                "\\quad Constant",
                "", 
                "\\quad Constant",
                "",
                "\\quad Subsidized silver plan {[}0/1{]}",
                "")
  
  table_list <- list()
  directories <- c("lowrisk_simplemh_censor0.2_main", 
                   "lowrisk_simplemh_censor0.5_main", 
                   "lowrisk_simplemh_censor0.2_switcher", 
                   "lowrisk_simplemh_censor0.5_switcher")
  for(i in directories){
    table_list[[i]] <- read.csv(paste0("../release/derived_paramests/specs/", i, "/model_results.csv"))
  }
  
  table <- matrix(nrow = length(rownames), ncol = length(table_list))
  for(i in seq_along(table_list)){
    if(grepl("main", directories[i], fixed = TRUE)){
      table[, i] <- perfectshuffle(table_list[[i]][c(1:6, 14), 3], 
        table_list[[i]][c(1:6, 14), 4])
    } else {
      table[, i] <- perfectshuffle(table_list[[i]][c(1:6, 13), 3], 
        table_list[[i]][c(1:6, 13), 4])      
    }
  }
  # reshuffle in order we want: 
  table <- table[, c(1, 2, 3, 4)]

  MakeLatexTableAdj(
    startcodelist = list(
      "\\begin{table}[H]",
      "\\begin{centering}",
      "\\begin{tabular}{lcccc}",
      "&  &  &  &  \\tabularnewline",
      "\\hline", 
      "\\hline", 
      "&  \\multicolumn{2}{c}{\\textbf{Main}} & \\multicolumn{2}{c}{\\textbf{Switchers}}\\tabularnewline",
      "&  \\textbf{(1)} & \\textbf{(2)} & \\textbf{(1)} & \\textbf{(2)}\\tabularnewline", 
      "\\hline", 
      "$\\alpha$ &  &  &  & \\tabularnewline"), 
    tableinnardslist = list(
      table[1:8, ], 
      table[9:10, ], 
      table[11:12, ], 
      table[13:14, ]), 
    rownames = list(
      rownames[1:8], 
      rownames[9:10], 
      rownames[11:12], 
      rownames[13:14]),
    stderrlist = list(T, T, T, T),
    tableinnardsroundvec = c(3, 3, 3, 3), 
    inbetweencodelistlist = list(
      list("\\hline", 
            "$\\omega$ &  &  &  & \\tabularnewline"), 
      list("\\hline", 
            "$\\psi$ &  &  &  & \\tabularnewline"),
      list("\\hline", 
            "$\\beta_{0}$ &  &  &  & \\tabularnewline",
            "\\quad Payer fixed-effects & $\\checkmark$ & $\\checkmark$ & $\\checkmark$ & $\\checkmark$\\tabularnewline")
    ),
    endcodelist = list(
      "\\hline",
      "$\\underline{c}$ & \\$20 & \\$50 & \\$20 & \\$50\\tabularnewline",
      "Number of &  &  &  & \\tabularnewline",
      "\\quad HH-year observations & \\multicolumn{2}{c}{1,044,742} & \\multicolumn{2}{c}{14,426}\\tabularnewline", # Note: these numbers can se found in se.csv files
      "\\quad insured HH-year observations & \\multicolumn{2}{c}{444,255} & \\multicolumn{2}{c}{5,184}\\tabularnewline",
      "\\hline",
      "\\hline",
      "\\end{tabular}\\caption{Main parameter estimates} \\label{tab:main_t_main_est}",
      "\\par\\end{centering}", 
      "\\end{table}")
  )
}
